package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DagLag;
import com.ruoyi.system.service.IDagLagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 查询延迟测试Controller
 * 
 * @author NovaTian
 * @date 2022-05-12
 */
@RestController
@RequestMapping("/system/lag")
public class DagLagController extends BaseController
{
    @Autowired
    private IDagLagService dagLagService;

    /**
     * 查询查询延迟测试列表
     */
    @PreAuthorize("@ss.hasPermi('system:lag:list')")
    @GetMapping("/list")
    public TableDataInfo list(DagLag dagLag)
    {
        startPage();
        List<DagLag> list = dagLagService.selectDagLagList(dagLag);
        return getDataTable(list);
    }

    /**
     * 导出查询延迟测试列表
     */
    @PreAuthorize("@ss.hasPermi('system:lag:export')")
    @Log(title = "查询延迟测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DagLag dagLag)
    {
        List<DagLag> list = dagLagService.selectDagLagList(dagLag);
        ExcelUtil<DagLag> util = new ExcelUtil<DagLag>(DagLag.class);
        util.exportExcel(response, list, "查询延迟测试数据");
    }

    /**
     * 获取查询延迟测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:lag:query')")
    @GetMapping(value = "/{uuid}")
    public AjaxResult getInfo(@PathVariable("uuid") String uuid)
    {
        return AjaxResult.success(dagLagService.selectDagLagByUuid(uuid));
    }

    /**
     * 新增查询延迟测试
     */
    @PreAuthorize("@ss.hasPermi('system:lag:add')")
    @Log(title = "查询延迟测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DagLag dagLag)
    {
        return toAjax(dagLagService.insertDagLag(dagLag));
    }

    /**
     * 修改查询延迟测试
     */
    @PreAuthorize("@ss.hasPermi('system:lag:edit')")
    @Log(title = "查询延迟测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DagLag dagLag)
    {
        return toAjax(dagLagService.updateDagLag(dagLag));
    }

    /**
     * 删除查询延迟测试
     */
    @PreAuthorize("@ss.hasPermi('system:lag:remove')")
    @Log(title = "查询延迟测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uuids}")
    public AjaxResult remove(@PathVariable String[] uuids)
    {
        return toAjax(dagLagService.deleteDagLagByUuids(uuids));
    }
}
